/*
 * @Author: xiaosihan 
 * @Date: 2024-05-28 19:47:08 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-05-28 20:24:39
 */


import { Group, AxesHelper, SpriteMaterial, Vector3, Sprite } from "three";
import arrowPNG from "./arrow.png";
import threeLoader from "three-base/threeLoader";
import scatterData from "./scatterData.json";

//散点组
export default class ScatterGroup extends Group {
    constructor() {
        super();
        this.init(scatterData)
    }

    //地图偏移量
    offset = new Vector3(-116.468994140625 * 5, 0, 40.25177764892578 * 5);

    texture = threeLoader.getTexture(arrowPNG);

    material = new SpriteMaterial({
        map: this.texture,
        color: 0xfffef4,
        fog: false,
        transparent: true,
        depthTest: false,
    })

    init(scatterDatas: Array<{ lng: number, lat: number }>) {

        scatterDatas.map((scatterData) => {
            const sprite = new Sprite(this.material);
            sprite.renderOrder = 23
            sprite.scale.set(0.2, 0.2, 0.2);
            let { lng, lat } = scatterData;
            let point = new Vector3(lng, 0.1, -lat).multiplyScalar(5).add(this.offset);
            sprite.position.copy(point);
            this.add(sprite);
        })
    }


    updateMatrix(): void {
        super.updateMatrix();
    }
}
